<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="db.ReceiveorderDAO"%>
<%@page import="db.ReceivepurmatDAO"%>
<%@page import="db.Receiveorder"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="db.Receivepurmat"%>
<%@page import="db.SubstoreDAO"%>
<%@page import="db.Substore"%>
<%@page import="db.AssignDAO"%>
<%@page import="db.Assign"%>
<%@ include file="/jsp/common/utility/logined.jsp" %>
<%
	WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
	ReceiveorderDAO receiveorderDao = (ReceiveorderDAO)ctx.getBean("ReceiveorderDAO");
	ReceivepurmatDAO receivepurmatDao = (ReceivepurmatDAO)ctx.getBean("ReceivepurmatDAO");
	SubstoreDAO substoreDao = (SubstoreDAO)ctx.getBean("SubstoreDAO");
	AssignDAO assignDao = (AssignDAO)ctx.getBean("AssignDAO");
	UserDAO userDao = (UserDAO)ctx.getBean("UserDAO");
	
	String idPar = request.getParameter("id");
	
	int id = 0;
	
	try{
		id = Integer.parseInt(idPar);
	}catch(RuntimeException r){
		id = 0;
	}
	
	Assign assign = assignDao.findById(1);
	User assignUser = (User)userDao.findById(assign.getUserId());
	request.setAttribute("assignUser",assignUser);
	
	Receiveorder receiveorder = receiveorderDao.findById(id);
	request.setAttribute("receiveorder",receiveorder);
	
	User storeUser = (User)userDao.findById(receiveorder.getReceiverUserId());
	request.setAttribute("storeUser",storeUser);
	
	Substore substore = substoreDao.findById(receiveorder.getSubStore());
	request.setAttribute("substore",substore);
	
	List receivepurmats = receivepurmatDao.findByReceiveOrderId(id);
	request.setAttribute("receivepurmats",receivepurmats);

	pageContext.forward("/vm/stock/modStock.vm");
%>